package org.anupta.realm.utils.others;

import java.util.Timer;
import java.util.TimerTask;

import org.anupta.realm.entity.dao.DAO;
import org.anupta.realm.entity.entities.Entity;

public class TimerThread {
	private Timer daoTimer = new Timer();
	
	public TimerThread(){
		daoTimer.schedule(new TimerTask() {
			public void run() {
				long time = System.currentTimeMillis();
				for(DAO<? extends Entity> dao : DAO.getDao()){
					dao.commit();
				}
				System.out.println("Dao save in : " + (System.currentTimeMillis() - time) + "ms");
			}
		}, Config.TIME_SAVE, Config.TIME_SAVE);
	}
}
